package com.yrn;

import com.yrn.bean.Person;
import javafx.application.Application;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainTest {

    public static void main(String[] args) {
        /*// xml文件方式创建bean容器
        // 传入类路径下的xml文件，返回一个容器
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml");
        Person person =(Person) applicationContext.getBean("person");
        */
        // 注解方式创建bean容器
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext("com.yrn.config");
        Person p = applicationContext.getBean(Person.class);
        String[] beanNamesForType = applicationContext.getBeanNamesForType(Person.class);
        for (String s : beanNamesForType) {
            System.out.println(s);
        }
        System.out.println(p);

    }






}
